// 云函数入口文件
const cloud = require('wx-server-sdk')

 //云开发环境初始化
 cloud.init({
  env: 'cloud1-7g1a0u3je2bf6f8d', //所对应的环境ID
  traceUser: true
})


exports.main = async(event, context) => {
  try {
    const result = await cloud.openapi.subscribeMessage.send({
      touser: event.openid, //要推送给那个用户
      page: 'pages/get/get', //要跳转到那个小程序页面
      data: {//推送的内容
        character_string16: {  // 订单号
          value: event.orderID
        },
        character_string11: {  // 取件码
          value: event.qujian
        },
        thing20: {   // 取件地点
          value: event.address
        },
        thing9: {  // 温馨提示
          value: '请尽快在该订单评论区上传身份码'
        },
      },
      templateId: 'y5vuXP2krfP6TloZ7iebiH2yoB8DJR3g3fjjcsGzcNY' //模板id
    })
    //console.log(result)
    //return result
    return result.errCode
  } catch (err) {
    console.log(err)
    return err
  }
}
